<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"  %>
<!DOCTYPE html>

<head>
    <meta charset="utf-8">
    <!--[if IE]><meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"><![endif]-->
    <title>大乱斗后台</title>
    <meta name="keywords" content="" />
    <meta name="description" content="" />
    <meta name="viewport" content="width=device-width">
    <link href="http://cdn.bootcss.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet">
    <link href="http://cdn.bootcss.com/font-awesome/4.6.3/css/font-awesome.min.css" rel="stylesheet">
    <link rel="stylesheet" href="/dld/admin/css/template_main.css">
</head>

<body>
	<jsp:include page="../common/header.jsp"></jsp:include>
        <!--/.navbar-collapse -->
        <div class="templatemo-content-wrapper">
            <div class="templatemo-content">
            	<div class="table-responsive">
		    	<table class="table table-bordered text-center">
		    	<button class="btn btn-default col-xs-3" onclick="window.location.href='adminMsgMngAction'">全部</button>
            	<button class="btn btn-default col-xs-3" onclick="window.location.href='adminMsgMngAction?type=adv'">广告</button>
            	<button class="btn btn-default col-xs-3" onclick="window.location.href='adminMsgMngAction?type=news'">新闻</button>
            	<button class="btn btn-default col-xs-3" onclick="window.location.href='adminMsgMngAction?type=bc'">广播</button>
					<tr>
						<th>主题</th>
						<th>封面</th>
						<th>类型</th>
						<th>浏览</th>
						<th>是否显示</th>
						<th>是否置顶</th>
						<th>编写时间</th> 
						<th>操作</th>
					</tr>
		     		<s:iterator value="msgList" status="st" var="list">
		    		<tr>
		    			<td><s:property value="#list.getTitle()"/></td>
		    			<td><img src="<s:property value="#list.getImg_url()"/>" style="height:40px;height:40px;"></td>
		    			<td><s:property value="#list.getType()"/></td>
		    			<td><s:property value="#list.getRead_num()"/></td>
		    			<td>
		    				<s:if test="#list.getIs_show() == 0">隐藏</s:if>
				    		<s:else>显示</s:else>
				    	</td>
		    			<td>
		    				<s:if test="#list.getIs_top() == 1">置顶</s:if>
				    		<s:else>普通</s:else>
				    	</td>
		    			<td><s:property value="#list.getCreated_at()"/></td>
		    			<td>
		    				<button class="btn bt-default" onclick="readContent('<s:property value="#list.getContent()"/>')">阅读</button>
			    			<button class="btn bt-default" onclick="window.location.href='adminEditMsgMngAction?id=<s:property value="#list.getId()"/>'">修改</button>
			    			<button class="btn bt-default" onclick=" if(confirm('是否确认删除?')){window.location.href='adminDeleteMsgMngAction?id=<s:property value="#list.getId()"/>'} ">删除</button>
		    			</td>
		    		</tr>
		    		</s:iterator>
		    	</table>
					<s:if test="%{pageBean.currentPage == 1}">
					<div class="btn btn-default" disabled="disabled">第一页</div><div class="btn btn-default" disabled="disabled">上一页</div>
					</s:if>
					<s:else>
						<a href="adminMsgMngAction?type=<s:property value="type"/>&page=1" class="btn btn-info">第一页</a>
						<a href="adminMsgMngAction?type=<s:property value="type"/>&page=<s:property value="%{pageBean.currentPage-1}"/>" class="btn btn-info">上一页</a>
					</s:else>
					<s:if test="%{pageBean.currentPage != pageBean.totalPage}">
						<a href="adminMsgMngAction?type=<s:property value="type"/>&page=<s:property value="%{pageBean.currentPage+1}"/>" class="btn btn-info">下一页</a>
						<a href="adminMsgMngAction?type=<s:property value="type"/>&page=<s:property value="pageBean.totalPage"/>" class="btn btn-info">最后一页</a>
					</s:if>
					<s:else>
						<div class="btn btn-default" disabled="disabled">下一页</div> <div class="btn btn-default" disabled="disabled">最后一页</div>
					</s:else>
					 共<s:property value="pageBean.allRow"/> 条记录
					共<s:property value="pageBean.totalPage"/> 页
					 当前第<s:property value="pageBean.currentPage"/>页
		    	</div>
		    	<button class="add-btn btn btn-info pull-right" onclick="window.location.href='adminAddMsgMngAction'">添加</button>
		    	<div class="read-content" style="display:none;"></div>
		    	<button class="back-btn btn btn-info pull-right" style="display:none;">返回</button>
            </div>
        </div>
    <jsp:include page="../common/footer.jsp"></jsp:include>
    <script src="http://cdn.bootcss.com/jquery/2.2.4/jquery.min.js"></script>
    <script src="http://cdn.bootcss.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
    <script src="/dld/admin/js/template_js.js"></script>
    <script>
    function readContent(content){
    	$("div.table-responsive").toggle();
    	$("div.read-content").html(content);
    	$("div.read-content").toggle();
    	
    	$("button.back-btn").toggle();
    	$("button.add-btn").toggle();
    	console.log(content);
    }
    $("button.back-btn").click(function(){
    	$("div.table-responsive").toggle();
    	$("div.read-content").toggle();
    	
    	$("button.back-btn").toggle();
    	$("button.add-btn").toggle();
    });
    function search(){
    	var like = $('#templatemo_search_box').val();
    	window.location.href = "adminMsgMngAction?type=<s:property value="type"/>&page=1&like=" + like;
    }
    </script>
</body>

</html>